package com.nd.android.u.ui.activity.chat_relative_quickreply;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.text.TextUtils.TruncateAt;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.common.android.utils.DisplayUtil;
import com.common.utils.StarAppUtils;
import com.nd.android.u.controller.bean.QuickReplyList;
import com.nd.android.u.ui.R;

public class QuickReplyAdapter extends BaseAdapter {

	private Context mContext;
	private QuickReplyList mQuickReplyList;
	public static final int ITEM_HEIGHT=40;
	public QuickReplyAdapter(Context context,QuickReplyList list){
		mQuickReplyList=list;
		mContext=context;
	}
	
	@Override
	public int getCount() {
		return mQuickReplyList.size();
	}

	@Override
	public Object getItem(int position) {
		return mQuickReplyList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		TextView view=(TextView)convertView;
		if (view==null){
			view=( TextView)LayoutInflater.from(mContext).inflate(R.layout.quick_reply_view, null);
			StarAppUtils.setViewTypeFace(view, false);
			view.setEllipsize(TruncateAt.END);
			AbsListView.LayoutParams lp=new AbsListView.LayoutParams(-1, DisplayUtil.dip2px(mContext, ITEM_HEIGHT));
			view.setLayoutParams(lp);
			StarAppUtils.setViewTypeFace(view, false);
		}
		view.setText(mQuickReplyList.get(position).getText());
		return view;
	}

	@TargetApi(Build.VERSION_CODES.CUPCAKE)
	public View getFooterView(){
		TextView view=( TextView)LayoutInflater.from(mContext).inflate(R.layout.quick_reply_view, null);
		view.setText(R.string.add);
		StarAppUtils.setViewTypeFace(view, false);
		view.setCompoundDrawablesWithIntrinsicBounds(R.drawable.type_select_btn_pressed, 0, 0, 0);
		AbsListView.LayoutParams lp=new AbsListView.LayoutParams(-1, DisplayUtil.dip2px(mContext, ITEM_HEIGHT));
		view.setLayoutParams(lp);
		return view;
	}
}
